<?php
include_once 'classes/DBClass.php';
include_once 'classes/User.php';
include_once 'configuration.php';

class Login{

	function __construct(){
			
	}
	function isAuthenticated(){
		if(isset($_SESSION['isAuthenticated']))
		return $_SESSION['isAuthenticated'];
		else return false;
	}
	function Authenticate($username,$password){

		if(!isset($_SESSION['isAuthenticated']))
		session_register("isAuthenticated");

		$mysql = new DBClass();
		//Stored Procedure
		$result = $mysql->Query("SELECT COUNT(username) as Count FROM user WHERE (username='".$username."' AND password = '".$password."')");
		
		if($result[0]["Count"]==1){
			//Match
			$_SESSION['isAuthenticated'] = true;
		}else{
			$_SESSION['isAuthenticated'] = false;
		}
	}

}
?>